﻿<%@ Page Language="C#" %>

<%
    
    //var validatePassKey = DateTime.Now;//时效性密文
    //DateTime requestToken=DateTime.MinValue;
    //DateTime.TryParse(VCommons.Encryptor.Utility.DecryptString(Request.QueryString["token"]), out requestToken);//当前密文　

    string type = Request.QueryString["type"];
    string url =VCommons.Encryptor.Utility.DecryptString(Request.QueryString["token"]);
    string flag = Request.QueryString["flag"];
     if (!string.IsNullOrWhiteSpace(url))
    {%>
//播放插件设置
var Player = {
    domain: 'eee114.com',
    msPerMonth: 24 * 60 * 60 * 1000,
    fileTypeHelper: function (file_type) {// 根据传入的文件类型，返回相应的插件地址
        var type_list = {
            'flash': '<a href="http://download.eee114.com/SoftWare/flashPlayer(Tsingda)%209.0.rar">FLASH播放器</a>',
            'acc': '<a href="http://download.eee114.com/SoftWare/accPlayer.rar">ACC播放器</a>',
            'vga': '<a href="http://download.eee114.com/SoftWare/tsingdaVGAPlayer.rar">VGA播放器</a>',
            'iac': '<a href="http://download.eee114.com/SoftWare/QDC_IAC_Player_Setup.rar">IAC播放器</a>',
            'videoPath': '<a href="http://download.eee114.com/SoftWare/MediaPlayPatch.rar">视频补丁</a>',
            'videoDecoder': '<a href="http://download.eee114.com/SoftWare/CodecPatch1.0.zip">视频解码器</a>',
            'tsplay': '<a href="http://download.eee114.com/SoftWare/TSPlay.rar">TSPlay</a>',
            'formuleEditor': '<a href="http://download.eee114.com/SoftWare/eduoffice.rar">公式编辑器</a>'
        };

        switch (file_type) {
            case 'html' || '.html' || 'htm' || '.htm':
                return type_list.videoPath + '，' + type_list.vga;
            case 'iac' || '.iac':
                return type_list.iac;
        }
    },
    //纯视频格式播放
    videoPlayer: {
        options: { width: 610, height: 480 }, //参数选项
        bgImage: '/Scripts/mediaplayer/videoloading.jpg', //背景图像
        flv: function (url) {
            jwplayer('mediaspace').setup({
                'flashplayer': '/Scripts/mediaplayer/player.swf',
                'file': url,
                'controlbar': 'bottom',
                'width': this.options.width,
                'height': this.options.height,
                'image': this.bgImage
            });
        },
        wmv: function (url) {
            //替换单引号
            if (str.indexOf("'") != -1) {
                str = str.replace("'", "%27");
            }

            var stringMediaPlayer = "<OBJECT id=\"mPlayer\" width=\"" + this.options.width + "\" height=\"" + this.options.height + "\" classid=\"CLSID:6BF52A52-394A-11D3-B153-00C04F79FAA6\">";
            stringMediaPlayer += " <param name=URL value=\'" + str + "\'>";
            stringMediaPlayer += " <param name=rate value=1>";
            stringMediaPlayer += " <param name=balance value=0>";
            stringMediaPlayer += " <param name=currentPosition value=0>";
            stringMediaPlayer += " <param name=playCount value=1>";
            stringMediaPlayer += " <param name=autoStart value=-1>";
            stringMediaPlayer += " <param name=currentMarker value=0>";
            stringMediaPlayer += " <param name=invokeURLs value=-1>";
            stringMediaPlayer += " <param name=baseURL value=>";
            stringMediaPlayer += " <param name=volume value=80>";
            stringMediaPlayer += " <param name=mute value=0>";
            stringMediaPlayer += " <param name=windowlessVideo value=-1>";
            stringMediaPlayer += " <param name=enabled value=-1>";
            stringMediaPlayer += " <param name=enableContextMenu value=0>";
            stringMediaPlayer += " <param name=fullScreen value=0>";
            stringMediaPlayer += " <param name=\"stretchToFit\" value=\"1\"> ";
            stringMediaPlayer += "</OBJECT>";
            $("#mediaspace").html(stringMediaPlayer);
        },
        swf: function (url) {
            var flashvars = {};
            flashvars.sn = "a00001";
            var params = {};
            params.menu = "true";
            params.quality = "autohigh";
            params.wmode = "opaque";
            params.allowfullscreen = "true";
            params.allowscriptaccess = "always";
            params.allownetworking = "all";
            var attributes = {};
            swfobject.embedSWF(url, "mediaspace", this.options.width, this.options.height, "9.0.0", "expressInstall.swf", flashvars, params, attributes);
        },
        mp4: function (url) {
            //高清及精华资源 rtmp
            if (url.toLowerCase().indexOf('/gaoqing/') != -1) {
                var streamer = "";
                var file = "";
                url = url.replace("http://jxwtkj.eee114.com:807/", "http://rtmp.eee114.com/");
                url = url.replace("http://jxdxkj.eee114.com/", "http://rtmp.eee114.com/");
                url = url.replace("http://cdn.eee114.com/", "http://rtmp.eee114.com/");
                url = url.replace("http://", "rtmp://");

                if (url.toLowerCase().indexOf('/jinghuaziyuan/') != -1) {
                    streamer = url.substring(0, url.toLowerCase().indexOf('/jinghuaziyuan/') + 15);
                    file = url.substr(url.toLowerCase().indexOf('/jinghuaziyuan/') + 15);
                }

                if (url.toLowerCase().indexOf('/gaoqing/') != -1) {
                    streamer = url.substring(0, url.toLowerCase().indexOf('/gaoqing/') + 9);
                    file = url.substr(url.toLowerCase().indexOf('/gaoqing/') + 9);
                }
                //alert(streamer + "==" + file);
                //rtmp play
                this.Mp4_Rtmp(streamer, file);
            }
            else {
                //http play
                this.Mp4_Http(url);
            }
        },
        Mp4_Http: function (fileUrl) { //通过Http播放MP4文件
            jwplayer('mediaspace').setup({
                'flashplayer': '/Scripts/mediaplayer/player.swf',
                'file': fileUrl,
                'autostart': "true",
                'controlbar': 'bottom',
                'width': this.options.width,
                'height': this.options.height,
                'image': this.bgImage,
                'http.startparam': 'start',
                'provider': 'http'
            });
        },
        Mp4_Rtmp: function (streamer, fileUrl) {  //通过Rtmp播放MP4文件
            jwplayer('mediaspace').setup({
                'flashplayer': '/Scripts/mediaplayer/player.swf',
                'id': 'playerIDRTMP',
                'autostart': "true",
                'width': this.options.width,
                'height': this.options.height,
                'controlbar': 'bottom',
                'provider': 'rtmp',
                'streamer': streamer,
                'file': fileUrl,
                'image': this.bgImage
            });
        },
        plays: function (fileType, cUrl, _options) {
            var isCdn = isCdn || "true";
            this.options = _options || this.options;
            var file_type = fileType;
            var file_path = Player.pressUrl(cUrl, isCdn);
            var path_type = file_path.substring(file_path.lastIndexOf('.'));
            if (path_type == '' || path_type.length > 5) {
                path_type = file_type;
            }
            path_type = path_type.toLowerCase();
            if (path_type == "flv" || path_type == ".flv") {
                this.flv(file_path);
            } else if (path_type == "wmv" || path_type == ".wmv" || path_type == "asf" || path_type == ".asf") {
                this.wmv(file_path);
            } else if (path_type == "swf" || path_type == ".swf") {
                this.swf(file_path);
            } else if (path_type == "mp4" || path_type == ".mp4") {
                this.mp4(file_path);
            }

            $("#wangtong").removeClass().addClass("ck_azp ck_hard");
            $("#dianxin").removeClass().addClass("ck_dx_hui ck_hard");

            // 绑定选择网通按钮方法
            $("#wangtong").click(function () {
                $("#dianxin").removeClass().addClass("ck_dx_hui ck_hard");
                $("#wangtong").removeClass().addClass("ck_azp ck_hard");
            });

            // 绑定选择电信按钮方法
            $("#dianxin").click(function () {
                $("#dianxin").removeClass().addClass("ck_dx ck_hard");
                $("#wangtong").removeClass().addClass("ck_azp_hui ck_hard");
            });
        }
    },
    //Html格式播放
    htmlPlayer: {
        //iframe跨域适应高度地址
        iframeHeight: {
            cnd_iframeHeight: "http://cdn.eee114.com/iframe.aspx?url=",
            dx_iframeHeight: "http://jxdxkj.eee114.com/iframe.aspx?url=",
            html_iframeHeight: "http://studygame.eee114.com/iframe.html?url=",
            wt_iframeHeight: "http://jxwtkj.eee114.com:807/iframe.aspx?url="
        },
        autoHeight: function () { // 自适应高度,不在同一域的对象，是不能相互操作的，只能通过ＵＲＬ地址把子页面的高度传过来
            var ifm = document.getElementById("iframeid");
            try {

                // 拿上来吧，否则当JS出错后，下面的代码不会执行了，呵呵
                if (cUrl.indexOf(".iac") != -1 || cUrl.indexOf(".itf") != -1) {
                    ifm.height = 700;
                    ifm.width = 1000;
                }
                // 结果为height=高度
                var hash = window.location.hash.slice(1).split("&")[0];
                // width=宽度
                var hash2 = window.location.hash.slice(1).split("&")[1].slice(0);
                if (hash2.slice(0, 1) == '#')
                    hash2 = hash2.slice(1);
                if (hash && /height=/.test(hash)) {
                    if (ifm != null) {
                        ifm.height = hash.replace("height=", "");
                        ifm.width = hash2.replace("width=", "");
                    }
                }
            } catch (e) {

                ifm.height = 1000;
            }

        },
        plays: function (cUrl, isCdn) {
            this.autoHeight();
            isCdn = isCdn || "true";
            cUrl = Player.pressUrl(cUrl, isCdn);
            if (isCdn.toLowerCase() == "true") {
                if (cUrl.indexOf("studygame.eee114.com") == -1) {
                    $("#iframeid").attr({ src: this.iframeHeight.cnd_iframeHeight + cUrl });
                } else {
                    $("#iframeid").attr({ src: this.iframeHeight.html_iframeHeight + cUrl });
                }
            } else {
                if (cUrl.indexOf("studygame.eee114.com") == -1) {
                    $("#iframeid").attr({ src: this.iframeHeight.wt_iframeHeight + cUrl });
                } else {
                    $("#iframeid").attr({ src: this.iframeHeight.html_iframeHeight + cUrl });
                }
            }

            // 判断文件类型是否iac
            if (cUrl.indexOf(".iac") != -1) {
                $("#iframeid").attr({ src: "http://www.eee114.com/resourcefile/Iac/main.htm?fileurl=" + cUrl });
            }

            if (cUrl.indexOf(".itf") != -1) {
                $("#iframeid").attr({ src: cUrl });
            }

            // 检测是否IE浏览器
            var isIE = (navigator.appName == "Microsoft Internet Explorer");
            if (!isIE) {
                var tip_message = '';
                tip_message += '检测到您使用的不是IE浏览器，为了您能正常播放本课程，建议使用IE浏览器。';
                tip_message += '<a href="/About/SoftwareDownload/" target="_blank">查看帮助</a>';

                $('.header-tip:last').slideDown(1000).html(tip_message);
            } else {
                var tip_message = '如不能正常播放视频请下载下列插件后重试，<a href="/About/SoftwareDownload/" target="_blank">查看帮助</a>';
                tip_message += '<br/>';
            }
            try {
                // 判断文件类型是否iac
                if (!(cUrl.indexOf(".iac") != -1)) {
                    $('.header-tip:last').slideDown(1000).html(tip_message + fileTypeHelper('html'));
                } else {
                    $('.header-tip:last').slideDown(1000).html(tip_message + fileTypeHelper('iac'));
                }
            } catch (e) {

            }
            var message = '<span class="ck_wxtis">温馨提醒：</span>为了保证您观看视频流畅性，我们已经为您推荐选择<strong>网通</strong>线路，您也可以根据需要进行线路切换。 ';
            $(".ck_tishix").html(message);

            $("#dianxin").removeClass().addClass("ck_mords ck_mord2 ck_yx1");
            $("#wangtong").removeClass().addClass("ck_mords ck_mord1");
            // 绑定选择网通按钮方法
            $("#wangtong").click(function () {
                $("#dianxin").removeClass().addClass("ck_mords ck_mord2 ck_yx1");
                $("#wangtong").removeClass().addClass("ck_mords ck_mord1 ");
            });

            // 绑定选择电信按钮方法
            $("#dianxin").click(function () {
                $("#dianxin").removeClass().addClass("ck_mords ck_mord2");
                $("#wangtong").removeClass().addClass("ck_mords ck_mord1 ck_yx");
            });

        }
    },
    //处理URl
    pressUrl: function (cUrl, isCdn) {
        if (isCdn.toLowerCase() == "true") {//cnd过来的
            cUrl = cUrl.replace("http://newtest.eee114.com/", "http://cdn.eee114.com/");
            cUrl = cUrl.replace("http://netclass.eee114.com/", "http://cdn.eee114.com/netclass/");
            cUrl = cUrl.replace("http://res.eee114.com/", "http://cdn.eee114.com/");
            cUrl = cUrl.replace("http://ltkt.eee114.com/", "http://cdn.eee114.com/");

        }
        else // 网通过来的
        {
            cUrl = cUrl.replace("http://newtest.eee114.com/", "http://jxwtkj.eee114.com/");
            cUrl = cUrl.replace("http://netclass.eee114.com/", "http://jxwtkj.eee114.com/netclass/");
            cUrl = cUrl.replace("http://res.eee114.com/", "http://jxwtkj.eee114.com/");
            cUrl = cUrl.replace("http://ltkt.eee114.com/", "http://jxwtkj.eee114.com/");

            // 2010-1-8网通80端口被封后修改
            cUrl = cUrl.replace("http://jxwtkj.eee114.com/", "http://jxwtkj.eee114.com:807/");
        }
        if (cUrl == "") {
            alert("课件地址有误,请与客服人员联系！");
        }
        //替换单引号
        if (cUrl.indexOf("'") != -1) {
            var reg = new RegExp("'", "g");
            cUrl = this.cUrl.replace(reg, "%27");
        }

        return cUrl;
    }
};
<%if (flag == "1")
  { %>
Player.videoPlayer.plays("<%=type%>", "<%=url%>");
<%}
  else
  { %>
  Player.htmlPlayer.plays("<%=url %>");
<%} %>
  <%}
    else
    {%>
console.log("Not OK");
<%} %>